package com.example.day1210_section_information.utils;

import ohos.media.image.ImageSource;
import ohos.media.image.PixelMap;

import java.io.InputStream;

public class PixelMapUtils {


    /**
     * 通过url加载网络图片
     *
     * @param imageUrl
     * @return
     */
    public static PixelMap createPixelMap(String imageUrl) {
        InputStream inputStream = HttpsUtils.getInputStream(imageUrl, "GET");
        ImageSource.SourceOptions sourceOptions = new ImageSource.SourceOptions();
        sourceOptions.formatHint = "image/jpeg";
        ImageSource imageSource = ImageSource.create(inputStream, sourceOptions);
        PixelMap pixelMap = imageSource.createPixelmap(null);
        return pixelMap;
    }

}
